//
//  ProjectTabBarVC.swift
//  TQGO
//
//  Created by YXY on 2018/7/9.
//  Copyright © 2018年 Techwis. All rights reserved.
//

import UIKit

class BaseTabBarConteoller: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBar.backgroundColor = .white
        self.setup(childVc: PromotionVC(), title: "Home", image: "icon_tabbar_default_promotion", selectedImage: "icon_tabbar_selected_promotion")
        self.setup(childVc: MultistageScrollingVC(), title: "多级滚动", image: "icon_tabbar_default_promotion", selectedImage: "icon_tabbar_selected_promotion")
        self.setup(childVc: PersonalCenterVC(), title: "信用付", image: "icon_tabbar_default_credit", selectedImage: "icon_tabbar_selected_credit")
        self.setup(childVc: UnicomAreaVC(), title: "购物车", image: "icon_tabbar_default_personalCenter", selectedImage: "icon_tabbar_selected_personalCenter")
        self.setup(childVc: ShopCartVC(), title: "我的", image: "icon_tabbar_default_personalCenter", selectedImage: "icon_tabbar_selected_personalCenter")
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func setup(childVc : UIViewController,title : String, image : String , selectedImage : String) {
        // 设置文字和图片
        childVc.navigationItem.title = title;
        childVc.tabBarItem.title = title;
        childVc.tabBarItem.image = UIImage.init(named: image)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        childVc.tabBarItem.selectedImage = UIImage.init(named: selectedImage)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        // 包装一个导航控制器, 添加导航控制器为tabbarcontroller的子控制器
        let nav = BaseNavigationController(rootViewController: childVc);
        self.addChild(nav);
    }
   
}
